<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>账务系统</title>
<link href="css/style_login.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.js"></script>
<script src="js/cloud.js" type="text/javascript"></script>

<script>
	$(function(){
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
	$(window).resize(function(){  
    $('.loginbox').css({'position':'absolute','left':($(window).width()-692)/2});
    })  
});  
	function login() {
		var result=valid( $(".loginuser").val(),$(".loginpwd").val());
		if(result){
		  $.ajax({  
	          url:"login",    
	          type:"post",  
	          data:{  
	        	  "username" : $(".loginuser").val(),
	        	  "password" : $(".loginpwd").val()
	          },  
	          success:function(data) {
	        	  if(data=="success"){  
	      			location.href="main";
	        	  }else{
	        		  $(".msg").append("<font style='color:red;font-size:16px'>登录失败</font>");
			      		$(".msg").css("background-color","#aaa");
			      		setTimeout(function () {
			      			location.href="/acct";
			      	}, 500);   		
	        	  }
	          }
	          
	        });	
		}else{
			alert("您输入的账号或密码格式有误");
			location.href=location.href;
		}
	}
	function valid(uname,pwd){
		exc1=/[a-zA-Z0-9_]{5,14}[a-zA-Z0-9_]$/;
		exc2=/^[A-Z][a-zA-Z0-9_]{4,13}[a-zA-Z0-9_]$/;
		if (exc1.test(uname)&&exc2.test(pwd))
			return true;
		else
			return false;
	}
	function toregit(){
		location.href="toregit";
	}
</script> 
</head>
<body style="background-color:#1c77ac; background-image:url(images/light.png); background-repeat:no-repeat; background-position:center top; overflow:hidden;">
  <div id="mainBody">
      <div id="cloud1" class="cloud"></div>
      <div id="cloud2" class="cloud"></div>
    </div>  
<div style="position:absolute;margin-top:50px;margin-left:750px;width:70px;height:20px;" class="msg"></div>

<div class="logintop">    
    <span>欢迎登录神州信息账务系统</span>    
    <ul>
    <li><a href="#">回首页</a></li>
    <li><a href="#">帮助</a></li>
    <li><a href="#">关于</a></li>
    </ul>    
    </div>
    
    <div class="loginbody">
    
    <span class="systemlogo"></span> 
       
    <div class="loginbox">
    <div style="margin-left:280px;margin-top:30px;font-size:22px;position:absolute;color: #703b3b94;">用户登录</div>
    <form  name="loginForm">
	    <ul>
	    <li><input name="username" type="text" class="loginuser" value="" onclick="JavaScript:this.value=''"/></li>
	    <li><input name="password" type="password" class="loginpwd" value="" onclick="JavaScript:this.value=''"/></li>
	    <li><input name="" type="button" class="loginbtn" value="登录"  onclick="login();"  /></li>
	    <li><input name="" type="button" class="loginbtn" style="position:absolute; margin-left:230px;margin-top:-57px" value="立即注册" onclick="toregit();"  /></li>
	    </ul>
    </form>
    
    </div>
    
    </div>
    
    <div class="loginbm">账务系统-交流学习-2018</div>
</body>
</html>